<%-- 
    Document   : risultatoRicerca
    Created on : 9-ago-2010, 15.33.04
    Author     : edoardo
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	try {
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script type="text/javascript" src="scripts/prototype.js"></script>
<script type="text/javascript" language="javascript1.5">

	function removeIdProgetto(theCheckBox){
		new Ajax.Request('addPrjToUtente.do?idProgetto='+theCheckBox.value+'&checked='+theCheckBox.checked,
				  {
				    method:'get',
				    onSuccess: function(transport){
				      var response = transport.responseText || "no response text";
				      if(response=="false"){
				      	alert('A questo profilo puo\' essere associato un solo progetto');
				      	theCheckBox.checked=false;
				      }
				    },
				    onFailure: function(){  }
				  });

	}
</script>
</head>
<body>
<table border="0">
	<tr>
		<td><a href="esci.do">Esci</a></td>
	</tr>

</table>

<form name="listaProgetti" action="wizardCreateUser.do?_finish"
	method="post"><input type="hidden" name="_page" value="1" /> <c:if
	test="${not empty listaProgetti}">
	<table width="100%">
		<tr style="border-bottom: thin">
			<td></td>
			<td>ID</td>
			<td>DESCRIZIONE</td>
		</tr>
		<c:forEach items="${listaProgetti}" var="item">
			<c:set var="contains" value="false" />
			<c:forEach var="sel" items="${progettiSelezionati}">
				<c:if test="${sel eq item.idProgetto}">
					<c:set var="contains" value="true" />
				</c:if>
			</c:forEach>
			<tr>
				<td><input type="checkbox" name="idProgetto"
					value="<c:out value='${item.idProgetto }'/>"
					onclick="removeIdProgetto(this)"
					<c:if test="${contains }">checked="true"</c:if>></td>
				<td><c:out value="${item.idProgetto}" /></td>
				<td><c:out value="${item.descrizione}" /></td>
			</tr>
		</c:forEach>

	</table>
	<table>
		<tr>
			<td align="right"><c:if test="${!currentPage.firstPage }">
				<a
					href="javascript:document.forms[0]._page.value=0;document.forms[0].action='wizardCreateUser.do?_target1&p=<c:out value='${prevPage }' />'; document.forms[0].submit();">prev</a>
			</c:if> <c:if test="${!currentPage.firstPage && !currentPage.lastPage }">	
				|</c:if> <c:if test="${!currentPage.lastPage }">
				<a
					href="javascript:document.forms[0]._page.value=0;document.forms[0].action='wizardCreateUser.do?_target1&p=<c:out value='${nextPage }' />'; document.forms[0].submit();">next</a>
			</c:if></td>
			<td>Pagina <c:out value="${currentPage.page }" /> di <c:out
				value="${currentPage.pagineTotali}" /></td>
			<td><input type="button" name="add" value="Crea utente"
				onclick="document.forms[0]._page.value=1;document.forms[0].action='wizardCreateUser.do?_finish'; document.forms[0].submit();" />
			</td>

		</tr>
	</table>

</c:if></form>
</body>
</html>
<%
	} catch (Exception e) {
		e.printStackTrace();
	}
%>
